<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <title>公司管理</title>
    <th:block th:include="statics/common/page/header"></th:block>
    <link rel="stylesheet" th:href="@{../statics/css/upload-template.css}"/>
</head>
<body>
<div id="companyBranch" v-cloak>
	<div v-show="showList">
        <Row class="search-panel-space">
            <div class="search-group">
                <i-col span="5">
                	<label class="search-label-20">名称:</label>
                    <i-input v-model="q.name" @on-enter="query" placeholder="名称" class="search-item-width-75"/>
                </i-col>
                <i-col span="6">
                	<label class="search-label-20">法人:</label>
                    <i-input v-model="q.legal" @on-enter="query" placeholder="公司法人" class="search-item-width-75"/>
                </i-col>
                <i-col span="5">
                	<label class="search-label-20">联系人:</label>
                    <i-input v-model="q.attn" @on-enter="query" placeholder="联系人" class="search-item-width-75"/>
                </i-col>
                <i-button @click="query">查询</i-button>
                <i-button @click="reloadSearch">重置</i-button>
            </div>
        </Row>    
        <Row :gutter="16">
            <div class="buttons-group">
                <i-button type="info" @click="add" th:if="${@shiroAuthService.hasPermission('org:companybranch:save')}">
                	<i class="fa fa-plus"></i>&nbsp;新增</i-button>
                <i-button type="warning" @click="update" th:if="${@shiroAuthService.hasPermission('org:companybranch:update')}">
                	<i class="fa fa-pencil-square-o"></i>&nbsp;修改</i-button>
                <i-button type="error" @click="del" th:if="${@shiroAuthService.hasPermission('org:companybranch:delete')}">
                	<i class="fa fa-trash-o"></i>&nbsp;删除</i-button>
            </div>
        </Row>
	    <table id="companyBranchGrid"></table>
    </div>

    <Card v-show="!showList">
        <p slot="title" style="height: 35px;">{{title}}
        	<i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
        </p>
		<i-form ref="formValidate" :model="orgCompanyBranch" :rules="ruleValidate" :label-width="120">
            <Form-item label="门店简称" prop="name" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.name" placeholder="门店简称"/>
            </Form-item>
            <Form-item label="所属公司" prop="companyId" style="width: 450px;" v-if="isAdmin">
                <i-input type="text" v-model="orgCompanyBranch.companyName" icon="eye" readonly="readonly"
                         @on-click="selectParentCompany" placeholder="所属公司" style="width: 320px;"/>
            </Form-item>
            <Form-item label="门店全称" prop="allName" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.allName" placeholder="门店全称"/>
            </Form-item>
            <Form-item label="门店编号" prop="serialNo" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.serialNo" placeholder="门店编号"/>
            </Form-item>
            <Form-item label="门店地址" prop="address" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.address" placeholder="门店地址"/>
            </Form-item>
            <Form-item label="营业执照" prop="license" style="width: 450px;">
                <div class="multiple-template-upload-list" v-for="item in uploadLicenseList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('license')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<i-progress :percent="item.percentage" hide-info></i-progress>
			        </template>
			    </div>
            
            	<Upload ref="uploadLicenseref" :show-upload-list="false" :default-file-list="uploadLicenseList" :on-success="handleSuccessLicense"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleLicenseImgBeforeUpload" multiple action="/sysUpload/uploadImg" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="联系人" prop="attn" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.attn" placeholder="联系人"/>
            </Form-item>
            <Form-item label="联系人电话" prop="phone" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.phone" placeholder="联系人电话"/>
            </Form-item>
            <Form-item label="法人" prop="legal" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.legal" placeholder="法人"/>
            </Form-item>
            <Form-item label="法人身份证正面" prop="idcardPositive" style="width: 450px;">
                <div class="multiple-template-upload-list" v-for="item in uploadIdcardPositiveList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('idcardPositive')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<!-- <img th:src="@{../statics/img/loading.gif}"> -->
			            <i-progress :percent="item.percentage" hide-info></i-progress>
			        </template>
			    </div>
            
            	<Upload ref="uploadIdcardPositiveref" :show-upload-list="false" :default-file-list="uploadIdcardPositiveList" :on-success="handleSuccessIdcardPositive"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleIdcardPositiveImgBeforeUpload" multiple action="/sysUpload/uploadImg" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="法人身份证反面" prop="idcardReverse" style="width: 450px;">
                <div class="multiple-template-upload-list" v-for="item in uploadIdcardReverseList">
			        <template v-if="item.status === 'finished' ">
			            <img :src="item.url">
			            <div class="multiple-template-upload-list-cover">
			                <Icon type="ios-eye-outline" @click.native="handleView(item)"></Icon>
			                <Icon type="ios-trash-outline" @click.native="handleRemove('idcardReverse')"></Icon>
			            </div>
			        </template>
			        <template v-else>
			        	<!-- <img th:src="@{../statics/img/loading.gif}"> -->
			        	<i-progress :percent="item.percentage" hide-info></i-progress>
			        </template>
			    </div>
            
            	<Upload ref="uploadIdcardReverseref" :show-upload-list="false" :default-file-list="uploadIdcardReverseList" :on-success="handleSuccessIdcardReverse"
			        :format="['jpg','jpeg','png']" :max-size="4096" :on-format-error="handleImgFormatError" :on-exceeded-size="handleImgMaxSize"
			        :before-upload="handleIdcardReverseImgBeforeUpload" multiple action="/sysUpload/uploadImg" style="display: inline-block;width:58px;">
			        <div class="multiple-template-upload-list" style="border: darkgrey 1px dashed;">
			        	<Icon type="camera" size="20"></Icon>
			        </div>
			    </Upload>
            </Form-item>
            <Form-item label="门店电话" prop="tel" style="width: 450px;">
                <i-input v-model="orgCompanyBranch.tel" placeholder="公司电话"/>
            </Form-item>
            <Form-item label="常用品牌" prop="brandList" style="width: 450px;">
            	<i-button type="primary" shape="circle" icon="ios-search" @click="selectBrandAll">选择车辆品牌</i-button>
           		<tag v-for="brandItem in orgCompanyBranch.brandList" type="dot" color="warning" :key="brandItem.id" :name="brandItem.id" closable @on-close="handleBrandRemove">{{brandItem.brand}}</tag>
            </Form-item>
            <Form-item>
                <i-button type="primary" @click="handleSubmit('formValidate')">提交</i-button>
                <i-button type="warning" @click="reload" style="margin-left: 8px"/>返回</i-button>
                <i-button type="ghost" @click="handleReset('formValidate')" style="margin-left: 8px">重置</i-button>
            </Form-item>
        </i-form>
	</Card>
</div>

<script th:src="@{../statics/js/org/companybranchs.js}"></script>
</body>
</html>